Dashboard.addWidget({ getId : function(){ return 'table-overview-widget'; }, getName : function(){ return 'Table Overview'; }, getDescription : function(){ return { en : 'Widget that display a tabular overview of the current model and goals status', de : 'Widget that display a tabular overview of the current model and goals status' }; }, getIconClass : function(){ return 'glyphicon glyphicon-th-large'; }, createContent : function(configuration, currentWidgetInstanceId){ var displayedGoalIdList = []; var displayedKpiIdList = []; var numModels = 0; var numKpi = 0; var numGoals = 0; var numErrors = 0; var numGoalSuccess = 0; var numGoalFailure = 0; var numGoalUnknown = 0; var infoList = {}; ModelManager.getKpiModelList().forEach(function(modelItem){ numModels++; infoList[modelItem.id] = { modelName : modelItem.name, objList : {} }; ModelManager.getTopLevelElementList(modelItem.id).forEach(function(item){ var _countRec = function(modelId, isGoal, objInfo){ if(isGoal){ if(displayedGoalIdList.indexOf(objInfo.id) != -1) return; displayedGoalIdList.push(objInfo.id); } else { if(displayedKpiIdList.indexOf(objInfo.id) != -1) return; displayedKpiIdList.push(objInfo.id); } if(isGoal) numGoals++; else numKpi++; var measure = null; var errorDescription = null; try{ measure = isGoal ? Dashboard.evaluateGoal(currentWidgetInstanceId, modelId, objInfo.id) : Dashboard.evaluateKpi(currentWidgetInstanceId, modelId, objInfo.id); }catch(e){ errorDescription = e; numErrors++; } infoList[modelItem.id].objList[objInfo.id] = { objectName : objInfo.name, isGoal : isGoal, measure : measure, errorDescription : errorDescription }; if(measure != null){ if(isGoal && measure.status>0) numGoalSuccess++; if(isGoal && measure.status<0) numGoalFailure++; if(isGoal && measure.status==0) numGoalUnknown++; } if(isGoal) objInfo.requiredGoalList.forEach(function(item){ _countRec(modelId, true, item); }); objInfo.requiredKpiList.forEach(function(item){ _countRec(modelId, false, item); }); }; var objInfo = item.isAGoal?ModelManager.getGoalInfo(modelItem.id, item.id):ModelManager.getKpiInfo(modelItem.id, item.id); _countRec(modelItem.id, item.isAGoal, objInfo); }); }); var _createCircleCode = function(color){ return''; } var ret = $('').append( $('').append( $('\ \ \ \ \ \ \ \ \ ') ).append( $('').append( $('').popover({ placement : 'auto right', container : 'body', html : true, title : 'Total Models Details', content : function(){ var html = '
Total modelsTotal KPIsTotal GoalsErrorsSucceeded Goals Failed GoalsUnevaluable Goals

'+numModels+'

'; html += ''; for(var modelInfoKey in infoList) html += ''; html += '
Models
'+infoList[modelInfoKey].modelName+'
'; return html; }(), trigger : 'hover' }) ).append( $('').popover({ placement : 'auto right', container : 'body', html : true, title : 'Total KPIs Details', content : function(){ var html = '

'+numKpi+'

'; for(var modelInfoKey in infoList){ html += ''; for(var objInfoKey in infoList[modelInfoKey].objList){ if(infoList[modelInfoKey].objList[objInfoKey].isGoal === false) html += ''; } } html += '
'+infoList[modelInfoKey].modelName+'
'+infoList[modelInfoKey].objList[objInfoKey].objectName+'
'; return html; }(), trigger : 'hover' }) ).append( $('').popover({ placement : 'auto right', container : 'body', html : true, title : 'Total Goals Details', content : function(){ var html = '

'+numGoals+'

'; for(var modelInfoKey in infoList){ html += ''; for(var objInfoKey in infoList[modelInfoKey].objList){ if(infoList[modelInfoKey].objList[objInfoKey].isGoal === true) html += ''; } } html += '
'+infoList[modelInfoKey].modelName+'
'+infoList[modelInfoKey].objList[objInfoKey].objectName+'
'; return html; }(), trigger : 'hover' }) ).append( $('').popover({ placement : 'auto right', container : 'body', html : true, title : 'Errors Details', content : function(){ var html = '

'+numErrors+'

'; for(var modelInfoKey in infoList){ var trHead = ''; var trBody = ''; for(var objInfoKey in infoList[modelInfoKey].objList){ var obj = infoList[modelInfoKey].objList[objInfoKey]; if(obj.isGoal === true && obj.measure === null && obj.errorDescription != null) trBody += ''; } if(trBody != '') html += trHead + trBody; trHead = ''; trBody = ''; for(var objInfoKey in infoList[modelInfoKey].objList){ var obj = infoList[modelInfoKey].objList[objInfoKey]; if(obj.isGoal === false && obj.measure === null && obj.errorDescription != null) trBody += ''; } if(trBody != '') html += trHead + trBody; } html += '
Errors in '+infoList[modelInfoKey].modelName+' Goals:
'+obj.objectName+''+obj.errorDescription+'
Errors in '+infoList[modelInfoKey].modelName+' KPIs:
'+obj.objectName+''+obj.errorDescription+'
'; return html; }(), trigger : 'hover' }) ).append( $('').popover({ placement : 'auto right', container : 'body', html : true, title : 'Succeeded Goals Details', content : function(){ var html = '

'+numGoalSuccess+' '+_createCircleCode('green')+'

'; for(var modelInfoKey in infoList){ html += ''; for(var objInfoKey in infoList[modelInfoKey].objList){ var obj = infoList[modelInfoKey].objList[objInfoKey]; if(obj.isGoal === true && obj.measure !== null && obj.measure.status>0) html += ''; } } html += '
'+infoList[modelInfoKey].modelName+'
'+obj.objectName+'
'; return html; }(), trigger : 'hover' }) ).append( $('').popover({ placement : 'auto right', container : 'body', html : true, title : 'Failed Goals Details', content : function(){ var html = '

'+numGoalFailure+' '+_createCircleCode('red')+'

'; for(var modelInfoKey in infoList){ html += ''; for(var objInfoKey in infoList[modelInfoKey].objList){ var obj = infoList[modelInfoKey].objList[objInfoKey]; if(obj.isGoal === true && obj.measure !== null && obj.measure.status<0) html += ''; } } html += '
'+infoList[modelInfoKey].modelName+'
'+obj.objectName+'
'; return html; }(), trigger : 'hover' }) ).append( $('').popover({ placement : 'auto right', container : 'body', html : true, title : 'Unevaluable Goals Details', content : function(){ var html = '

'+numGoalUnknown+' '+_createCircleCode('grey')+'

'; for(var modelInfoKey in infoList){ html += ''; for(var objInfoKey in infoList[modelInfoKey].objList){ var obj = infoList[modelInfoKey].objList[objInfoKey]; if(obj.isGoal === true && obj.measure !== null && obj.measure.status==0) html += ''; } } html += '
'+infoList[modelInfoKey].modelName+'
'+obj.objectName+'
'; return html; }(), trigger : 'hover' }) ) ) ); return ret; }, getConfiguration : function(){ return {}; }, createConfiguration : function(presetConfig){ return { nodeElement : null, okHandler : function(){return {};} }; }, getPreferredSize : function(){ return {w:10, h:3}; } });